#ifndef __QAHCONTROL_H__
#define __QAHCONTROL_H__


#include <stdio.h>
#include <gtk/gtk.h>

#include <string>
#include <list>
#include <vector>

#include "qaholom.h"

using namespace std;


/////////////////////////////////////////////////////////////////////////////////////////
// QahControl class declaration

class QahControl : public QahWidget 
{
protected:
   unsigned long    controlId;
   unsigned long    command;
   
public:
   QahControl() {}
   QahControl(unsigned long id) : controlId(id) {}
};

// ====[ QahButton ]=====================================================================
//
class QahButton : public QahControl
{
public: // property members & operations
   QahProperty<char*>   label;
   
   void __init_properties() 
   {
      QahControl::__init_properties();
      
      label.init(egoWidget, "label");
   }

   void setLabel(const char* str) {  gtk_button_set_label(GTK_BUTTON(egoWidget), str); }
   
public:
   QahButton() 
   {
       egoWidget = (GtkWidget*) gtk_button_new();
       
       __init_properties();
   }
   
   QahButton(const char* label)
   {
       egoWidget = (GtkWidget*) gtk_button_new_with_label(label);
       
       __init_properties();
   }
   
   QahButton(QahDUMMY dummy) { /* dummy function for child class' constructor function */ }
};

// ====[ QahLabel ]=====================================================================
//
class QahLabel : public QahControl
{
public: // property members & operations
   QahProperty<char*>    label;
   QahProperty<bool>     useUnderline;
   
   void __init_properties() 
   {
      label.init(egoWidget, "label");
      useUnderline.init(egoWidget, "user-underline");      
   }
   

public:
   QahLabel(const char* label) 
   {
      egoWidget = gtk_label_new(label);
      
      QahControl::__init_properties();
      QahLabel::__init_properties();
   }

};

// ====[ QahRadioButton ]=====================================================================
// simple GTK_RADIO_BUTTON wrapper
class QahRadioButton : public QahControl
{
public:
public:
   QahRadioButton()
   {
   }
};

// ====[ QahRadioBox ]=====================================================================
// a composited radio buttons for easy use.
class QahRadioBox : public QahControl
{
public:
   vector<QahRadioButton>   buttonElements;
};


// ====[ QahEntryBox ]=====================================================================
//
class QahEntryBox : public QahControl {};

// ====[ QahComboBox ]=====================================================================
//
class QahComboBox : public QahControl
{
public: // property members & operations
   QahProperty<int>  active;
   QahProperty<bool> addTearoffs;

   void __init_properties() 
   {
      active.init(egoWidget, "active");
      addTearoffs.init(egoWidget, "add-tearoffs");
   }

protected:
   void __append_text(const char* str) 
   {
      gtk_combo_box_append_text((GtkComboBox*) egoWidget, str);
      return;
   }

public:
   QahComboBox() 
   {
      egoWidget = gtk_combo_box_new_text();
      
      QahControl::__init_properties();
      QahComboBox::__init_properties();
   }
   
   void appendText(const char* str1       , const char* str2 = NULL, 
                          const char* str3 = NULL, const char* str4 = NULL, 
                          const char* str5 = NULL, const char* str6 = NULL,
                          const char* str7 = NULL, const char* str8 = NULL, 
                          const char* str9 = NULL, const char* str0 = NULL)
        {
           
           __append_text(str1);
           
           if (str2) __append_text(str2);
           if (str3) __append_text(str3);
           if (str4) __append_text(str4);
           if (str5) __append_text(str5);
           if (str6) __append_text(str6);
           if (str7) __append_text(str7);
           if (str8) __append_text(str8);
           if (str9) __append_text(str9);
           if (str0) __append_text(str0);
           // other strings ...
           return ;
        }
        
   void appendText(const char* texts[], int size) 
   {
      return ;
   }
};

// ====[ QahSlider ]=====================================================================

class QahSlider : public QahControl
{
protected:
   GtkAdjustment*   adjustment;

public:
   QahSlider()
   {
      // initializes adjustment widget.
   }
};

class QahVSlider : public QahSlider { };
class QahHSlider : public QahSlider { };

// ====[ QahToggleButton ]=====================================================================
//
class QahToggleButton : public QahButton 
{
public:
   QahProperty<bool>  active;
   QahProperty<bool>  drawIndicator;
   QahProperty<bool>  inconsistent;
   
   void __init_properties() 
   {
      active.init(egoWidget, "active");
      drawIndicator.init(egoWidget, "draw-indicator");
      inconsistent.init(egoWidget, "inconsistent");
   }

public:
   void onToggled(GtkToggleButton* toggleButton) 
   {
      QahToggleButton  button(toggleButton);
      
      if (button.active == true) 
      {
         // do something.
      }
   }
   
public:
   QahToggleButton() 
   {
      egoWidget = gtk_toggle_button_new();
      __init_properties();
   }
   
   QahToggleButton(GtkToggleButton* widget) { egoWidget = GTK_WIDGET(widget); __init_properties(); }  
   QahToggleButton(QahDUMMY dummy) : QahButton(dummy) { }
};

// ====[ QahCheckButton ]=====================================================================
//
class QahCheckButton : public QahToggleButton
{
public:
   QahCheckButton(const char* label) : QahToggleButton(QahDUMMY()) 
   {
      egoWidget = gtk_check_button_new_with_mnemonic(label);
   }
};




#endif
